home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / iutil / last_page.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-18  |  690 b   |  33 lines

  1. # include    <ingres.h>
  2. # include    <access.h>
  3. # include     <opsys.h>
  4.  
  5. /*
  6. **    LAST_PAGE -- computes a tid for the last page in the relation.
  7. */
  8.  
  9. last_page(d, tid, buf)
  10. register DESC        *d;
  11. register TID        *tid;
  12. register struct accbuf    *buf;
  13. {
  14.     long        lpage;
  15.     struct stat    stats;
  16.  
  17.     if ((buf != 0) && (abs(d->reldum.relspec) == M_HEAP) && (buf->mainpg == 0) && (buf->ovflopg == 0))
  18.         lpage = buf->thispage;
  19.     else
  20.     {
  21.         if (fstat(d->relfp, &stats))
  22.             syserr("last_page: fstat err %.14s", d->reldum.relid);
  23.         lpage = stats.st_size / PGSIZE - 1;
  24. #        ifdef xATR2
  25.         if (tTf(26, 8))
  26.             printf("fstat-lp %.12s %ld\n", d->reldum.relid, lpage);
  27. #        endif
  28.     }
  29.     stuff_page(tid, &lpage);
  30.     tid->line_id = 0;
  31.     return (0);
  32. }
  33.